package com.betterjr.modules.application.entity;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.selectkey.SerialGenerator;

/**
 * 
 * @ClassName: ApplicationOperorg 
 * @Description: t_ams_application_operorg 应用企业机构表 
 * @author xuyp
 * @date 2017年11月17日 下午6:04:23 
 *
 */
@Access(AccessType.FIELD)
@Entity
@Table(name = "t_ams_application_operorg")
public class ApplicationOperorg implements BetterjrEntity {

    /** 
     * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) 
     */
    private static final long serialVersionUID = -6096003148821228250L;

    /**
     * 流水号
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "流水号", comments = "流水号")
    private Long id;

    /**
     * 应用id
     */
    @Column(name = "n_application_id", columnDefinition = "INTEGER")
    @MetaData(value = "应用id", comments = "应用id")
    private Long applicationId;

    /**
     * 操作机构
     */
    @Column(name = "c_operorg", columnDefinition = "VARCHAR")
    @MetaData(value = "操作机构", comments = "操作机构")
    private String operOrg;

    /**
     * 状态 1未生效 2已生效 9已失效
     */
    @Column(name = "c_businStatus", columnDefinition = "VARCHAR")
    @MetaData(value = "状态 1未生效 2已生效 9已失效", comments = "状态 1未生效 2已生效 9已失效")
    private String businStatus;

    /**
     * 分组id
     */
    @Column(name = "n_applicationGroup_id", columnDefinition = "INTEGER")
    @MetaData(value = "分组id", comments = "分组id")
    private Long applicationGroupId;

    /**
     * 类型id
     */
    @Column(name = "n_applicationType_id", columnDefinition = "INTEGER")
    @MetaData(value = "类型id", comments = "类型id")
    private Long applicationTypeId;

    @Transient
    private String applicationName;

    @Transient
    private String applicationGroupName;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getApplicationId() {
        return applicationId;
    }

    public void setApplicationId(Long applicationId) {
        this.applicationId = applicationId;
    }

    public String getOperOrg() {
        return operOrg;
    }

    public void setOperOrg(String operOrg) {
        this.operOrg = operOrg;
    }

    public String getBusinStatus() {
        return businStatus;
    }

    public void setBusinStatus(String businStatus) {
        this.businStatus = businStatus;
    }

    public Long getApplicationGroupId() {
        return applicationGroupId;
    }

    public void setApplicationGroupId(Long applicationGroupId) {
        this.applicationGroupId = applicationGroupId;
    }

    public Long getApplicationTypeId() {
        return applicationTypeId;
    }

    public void setApplicationTypeId(Long applicationTypeId) {
        this.applicationTypeId = applicationTypeId;
    }

    public String getApplicationName() {
        return applicationName;
    }

    public void setApplicationName(String applicationName) {
        this.applicationName = applicationName;
    }

    public String getApplicationGroupName() {
        return applicationGroupName;
    }

    public void setApplicationGroupName(String applicationGroupName) {
        this.applicationGroupName = applicationGroupName;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((applicationGroupId == null) ? 0 : applicationGroupId.hashCode());
        result = prime * result + ((applicationId == null) ? 0 : applicationId.hashCode());
        result = prime * result + ((applicationTypeId == null) ? 0 : applicationTypeId.hashCode());
        result = prime * result + ((businStatus == null) ? 0 : businStatus.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((operOrg == null) ? 0 : operOrg.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        ApplicationOperorg other = (ApplicationOperorg) obj;
        if (applicationGroupId == null) {
            if (other.applicationGroupId != null) return false;
        } else if (!applicationGroupId.equals(other.applicationGroupId)) return false;
        if (applicationId == null) {
            if (other.applicationId != null) return false;
        } else if (!applicationId.equals(other.applicationId)) return false;
        if (applicationTypeId == null) {
            if (other.applicationTypeId != null) return false;
        } else if (!applicationTypeId.equals(other.applicationTypeId)) return false;
        if (businStatus == null) {
            if (other.businStatus != null) return false;
        } else if (!businStatus.equals(other.businStatus)) return false;
        if (id == null) {
            if (other.id != null) return false;
        } else if (!id.equals(other.id)) return false;
        if (operOrg == null) {
            if (other.operOrg != null) return false;
        } else if (!operOrg.equals(other.operOrg)) return false;
        return true;
    }

    @Override
    public String toString() {
        return "ApplicationOperorg [id=" + id + ", applicationId=" + applicationId + ", operOrg=" + operOrg
                + ", businStatus=" + businStatus + ", applicationGroupId=" + applicationGroupId + ", applicationTypeId="
                + applicationTypeId + "]";
    }

    public void saveAddValue() {
        this.setId(SerialGenerator.getLongValue("ApplicationOperorg.id"));
    }

}
